!isEmpty(PRI_INCLUDED):error("sii-storm.pri already included")
PRI_INCLUDED = 1

defineReplace(cleanPath) {
    win32:1 ~= s|\\\\|/|g
    contains(1, ^/.*):pfx = /
    else:pfx =
    segs = $$split(1, /)
    out =
    for(seg, segs) {
        equals(seg, ..):out = $$member(out, 0, -2)
        else:!equals(seg, .):out += $$seg
    }
    return($$join(out, /, $$pfx))
}

defineReplace(targetPath) {
    return($$replace(1, /, $$QMAKE_DIR_SEP))
}

defineReplace(qtLibraryName) {
   unset(LIBRARY_NAME)
   LIBRARY_NAME = $$1
   CONFIG(debug, debug|release) {
      !debug_and_release|build_pass {
          mac:RET = $$member(LIBRARY_NAME, 0)_debug
              else:win32:RET = $$member(LIBRARY_NAME, 0)d
      }
   }
   isEmpty(RET):RET = $$LIBRARY_NAME
   return($$RET)
}

defineTest(minQtVersion) {
    maj = $$1
    min = $$2
    patch = $$3
    isEqual(QT_MAJOR_VERSION, $$maj) {
        isEqual(QT_MINOR_VERSION, $$min) {
            isEqual(QT_PATCH_VERSION, $$patch) {
                return(true)
            }
            greaterThan(QT_PATCH_VERSION, $$patch) {
                return(true)
            }
        }
        greaterThan(QT_MINOR_VERSION, $$min) {
            return(true)
        }
    }
    return(false)
}

# For use in custom compilers which just copy files
win32:i_flag = i
defineReplace(stripSrcDir) {
    win32 {
        !contains(1, ^.:.*):1 = $$OUT_PWD/$$1
    } else {
        !contains(1, ^/.*):1 = $$OUT_PWD/$$1
    }
    out = $$cleanPath($$1)
    out ~= s|^$$re_escape($$PWD/)||$$i_flag
    return($$out)
}

isEmpty(TEST):CONFIG(debug, debug|release) {
    !debug_and_release|build_pass {
        TEST = 1
    }
}

isEmpty(APP_LIBRARY_BASENAME) {
    APP_LIBRARY_BASENAME = lib
}

DEFINES += APP_LIBRARY_BASENAME=\\\"$$APP_LIBRARY_BASENAME\\\"

equals(TEST, 1) {
    QT +=testlib
    DEFINES += WITH_TESTS
}

APP_SOURCE_TREE = $$PWD
isEmpty(APP_BUILD_TREE) {
    sub_dir = $$_PRO_FILE_PWD_
    sub_dir ~= s,^$$re_escape($$PWD),,
    APP_BUILD_TREE = $$cleanPath($$OUT_PWD)
    APP_BUILD_TREE ~= s,$$re_escape($$sub_dir)$,,
}

APP_NAME = sii-storm
APP_PATH = $$APP_BUILD_TREE/bin
macx {
    APP_TARGET   = "Sii-Storm"
    APP_LIBRARY_PATH = $$APP_PATH/$${APP_TARGET}.app/Contents/PlugIns
    APP_PLUGIN_PATH  = $$APP_LIBRARY_PATH
    APP_LIBEXEC_PATH = $$APP_PATH/$${APP_TARGET}.app/Contents/Resources
    APP_DATA_PATH    = $$APP_PATH/$${APP_TARGET}.app/Contents/Resources
    APP_DOC_PATH     = $$APP_DATA_PATH/doc
    APP_BIN_PATH     = $$APP_PATH/$${APP_TARGET}.app/Contents/MacOS
    contains(QT_CONFIG, ppc):CONFIG += ppc x86
    copydata = 1
} else {
    win32 {
        contains(TEMPLATE, vc.*)|contains(TEMPLATE_PREFIX, vc):vcproj = 1
        APP_TARGET   = $$APP_NAME
    } else {
        APP_TARGET   = $$APP_NAME
    }
    APP_LIBRARY_PATH = $$APP_BUILD_TREE/$$APP_LIBRARY_BASENAME/$$APP_NAME
    APP_PLUGIN_PATH  = $$APP_LIBRARY_PATH/plugins
    APP_LIBEXEC_PATH = $$APP_PATH # FIXME
    APP_DATA_PATH    = $$APP_BUILD_TREE/share/$$APP_NAME
    APP_DOC_PATH     = $$APP_BUILD_TREE/share/doc/$$APP_NAME
    APP_BIN_PATH     = $$APP_PATH
    !isEqual(APP_SOURCE_TREE, $$APP_BUILD_TREE):copydata = 1
}

INCLUDEPATH += $$APP_SOURCE_TREE/src/libs
LIBS += -L$$APP_LIBRARY_PATH

#DEFINES += QT_NO_CAST_FROM_ASCII
#DEFINES += QT_NO_CAST_TO_ASCII
!macx:DEFINES += QT_USE_FAST_OPERATOR_PLUS QT_USE_FAST_CONCATENATION

linux-g++-* {
    # Bail out on non-selfcontained libraries. Just a security measure
    # to prevent checking in code that does not compile on other platforms.
    QMAKE_LFLAGS += -Wl,--allow-shlib-undefined -Wl,--no-undefined
}

win32-msvc* {
    #Don't warn about sprintf, fopen etc being 'unsafe'
    DEFINES += _CRT_SECURE_NO_WARNINGS
}
